import java.util.Scanner;
import com.mysql.jdbc.Statement;

public class Test {
	public static void main(String args[]){
		connect connect = new connect();
		java.sql.Statement stmt = connect.doConnect("ip", 3306, "teacher","root","密码");
		
		Scanner input=new Scanner(System.in);
		TeacherSystem system=new TeacherSystem();
		system.welcome();
		//死循环进行功能重复
		int x = 1;
		while(x!=0) {
			system.showMenu();
			String sql = ""; 
			System.out.println("请输入选择的功能");
			x=input.nextInt();
		    switch(x){
		    case 1:
		    	sql = "SELECT id,name,age,nation,gender,work,academy FROM teacher;";
		    	system.showAll(stmt,sql);
		    	break;
		    case 2:
		    	sql = "";
		    	system.addStudent(stmt,sql);
		    	break;
		    case 3:
		    	system.findByid(stmt,sql);
		    	break;
		    case 4:
		    	System.out.println("请输入要查询的教师姓名：");
		    	String name = input.next();
//		    	SELECT * FROM teacher WHERE name = '唐玄奘';
		    	sql = "SELECT * FROM teacher WHERE name ='" +name+"';";
//		    	System.out.println(sql);
		    	system.findByname(stmt,sql);
		    	break;
		    case 5:
		    	sql = "";
		    	if(system.removeStu(stmt,sql)) {
		    		System.out.println("删除成功");
		    	}
		    	else {
		    		System.out.println("删除教师信息失败");
		    	}
		    	break;
		    case 6:
		    	if(system.exchangeStu(stmt,sql)) {
		    		System.out.println("修改成功");
		    	}
		    	else {
		    		System.out.println("修改教师信息失败");
		    	}
		    	break;
		    case 7:
		    	system.exit();
		    	System.exit(0);
		    default:
		    	System.out.println("请选择正确的功能");
		    }
			
		}
	}

}